package com.muyu.payment.domain.model;

import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.common.core.annotation.Excel;
import com.muyu.payment.domain.PaymentIndent;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;

/**
 * 支付订单分页查询模型
 *
 * @author muyu
 * @date 2025-09-18
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "支付订单分页查询模型")
public class PaymentIndentPageQueryModel {

    /**
     * 主键ID
     */
    @Schema(description = "主键ID")
    private Long id;

    /**
     * 订单号
     */
    @Excel(name = "订单号")
    @Schema(description = "订单号")
    private String orderNo;

    /**
     * 订单金额
     */
    @Excel(name = "订单金额")
    @Schema(description = "订单金额")
    private BigDecimal amount;

    /**
     * 用户ID
     */
    @Excel(name = "用户ID")
    @Schema(description = "用户ID")
    private Long userId;

    /**
     * 支付状态
     */
    @Excel(name = "支付状态")
    @Schema(description = "支付状态")
    private Integer orderStatus;

    /**
     * 状态名称
     */
    @Schema(description = "状态名称")
    private String statusName;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "创建时间")
    private Date createTime;

    /**
     * 订单名称
     */
    @Excel(name = "订单名称")
    @Schema(description = "订单名称")
    private String subject;

    /**
     * 订单描述
     */
    @Excel(name = "订单描述")
    @Schema(description = "订单描述")
    private String body;

    /**
     * 订单过期时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "订单过期时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "订单过期时间")
    private Date expireTime;

    /**
     * 构建分页查询模型
     * @param paymentIndent 支付订单实体
     * @return 分页查询模型
     */
    public static PaymentIndentPageQueryModel infoBuild(PaymentIndent paymentIndent) {
        return PaymentIndentPageQueryModel.builder()
                .id(paymentIndent.getId())
                .orderNo(paymentIndent.getOrderNo())
                .amount(paymentIndent.getAmount())
                .userId(paymentIndent.getUserId())
                .orderStatus(paymentIndent.getOrderStatus())
                .createTime(paymentIndent.getCreateTime())
                .subject(paymentIndent.getSubject())
                .body(paymentIndent.getBody())
                .expireTime(paymentIndent.getExpireTime())
                .build();
    }
}